Return to doc.sitecore.com

Valid for Sitecore 5.3
How do I create a new database for media files in Sitecore 5.3?

Q:

Could you please write the steps required to add a new database for media in Sitecore 5.3?
We want to use a separate database to hold images for the site; they will be proxied into the master database.

A: 

NOTE: This scenario is applicable to Sitecore 5.3.0 Build 070215, Microsoft SQL Server 2005 and serverMode="File" (web.config connections setting).

Follow the steps below to add a new database to Sitecore 5.3:

Create a database file:

    1. Duplicate a web database with the log file (sc53Web_Data.MDF and sc53Web_Data_log.ldf). 
    2. Rename the new db files to sc53Media_Data.MDF and sc53Media_Data_log.ldf. 

Note: The name “Media” is an example name used further in this article.  

To attach the database to Sitecore: 

  1. Edit the FileConnections.config file in the /App_Config/SqlServer directory:
    Add a connection to the /configuration section:
     

    <Media>user id=$(user);password=$(password);Data Source=$(serverName);AttachDBFileName=$(dataFolder)$(prefix)Media_Data.mdf</ Media > 

     
  2. Edit the web.config file:
    Add a database node to the /Sitecore/databases section. Copy the /Sitecore/databases/database[id=”web”] node and paste it below with the following modifications:
    Change the database id to the connection id defined on step 1 (Media in our case) and the include string under prefetch node (change Web.config to Master.config):
     

          <!-- Media -->
          <database id="Media" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
            <param desc="name">$(id)</param>
            <securityEnabled>true</securityEnabled>
            <dataProviders hint="list:AddDataProvider">
              <dataProvider ref="dataProviders/main" param1="$(id)">
                <disableGroup>publishing</disableGroup>
                <prefetch hint="raw:AddPrefetch">
                  <sc.include file="/App_Config/Prefetch/Common.config" />
                  <sc.include file="/App_Config/Prefetch/Master.config" />
                </prefetch>
              </dataProvider>
            </dataProviders>
            <proxiesEnabled>false</proxiesEnabled>
            <proxyDataProvider ref="proxyDataProviders/main" param1="$(id)" />
            <cacheSizes hint="setting">
              <children>100KB</children>
              <credentials>100KB</credentials>
              <data>20MB</data>
              <items>10MB</items>
              <parents>100KB</parents>
              <paths>500KB</paths>
            </cacheSizes>
          </database> 

Now you can add files to the newly created Media database (see the screenshot below): 

/upload/sdn5/faq/media/create new database/mediadb.png

Switch to the master database and create a proxy item for the Images folder (see below):

Refer to the Using Proxy Items in Sitecore 5.3 article to learn how to create proxy items. 

/upload/sdn5/faq/media/create new database/proxy_master.png

The proxy item has now been created in the master database (see the screenshot below): 

/upload/sdn5/faq/media/create new database/masterdb.png

Important Note: For this setup to work, you need to enable proxies in the web database (set the <proxiesEnabled> setting to true). Alternatively, you may set <publishVirtualItems> to true in the master database but in this case the connection between the virtual item and its source will no longer exist.